'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('edu_users', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER.UNSIGNED,
      },
      type: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        defaultValue: 0,
        comment: '用户分类:0-管理员,1-子公司,2-子公司校区,3-老师,4-学生',
      },
      status: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        defaultValue: 1,
        comment: '用户状态：0-禁用,1-正常,2-会员失效',
      },
      origin: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        defaultValue: 0,
        comment:
          '用户来源：0-未知,1-pc注册,2-小程序,3-android,4-ios,5-微信公众号,6-wap,7-微信扫码注册,8-批量导入',
      },
      is_real: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        defaultValue: 0,
        comment: '是否显示真实姓名',
      },
      sex: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        defaultValue: 0,
        comment: '性别：0-无,1-男,2-女',
      },
      start_time: {
        type: Sequelize.DATE,
        comment: '会员开始时间',
      },
      end_time: {
        type: Sequelize.DATE,
        comment: '会员结束时间',
      },
      score: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        defaultValue: 0,
        comment: '积分，比例是 1:100',
      },
      grade: {
        allowNull: false,
        type: Sequelize.DECIMAL(4, 2).UNSIGNED,
        defaultValue: '0.00',
        comment: '星级评分',
      },
      username: {
        allowNull: false,
        type: Sequelize.STRING,
        unique: true,
        comment: '用户名',
      },
      password: {
        allowNull: false,
        type: Sequelize.STRING,
        comment: '密码',
      },
      mobile: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '手机号码',
      },
      email: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '邮箱',
      },
      avatar: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '头像，图片地址',
      },
      nickname: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '昵称',
      },
      real_name: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '真实姓名',
      },
      id_card: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '身份证号码',
      },
      wechat_official_openid: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '微信公众号openid',
      },
      wechat_mini_openid: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '微信小程序openid',
      },
      wechat_native_openid: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '微信扫码登录openid',
      },
      wechat_unionid: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '微信unionid',
      },
      label: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '标签，多个标签用英文,分割',
      },
      description: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '个人描述',
      },
      deleted_at: {
        type: Sequelize.DATE,
      },
      created_at: {
        allowNull: false,
        type: Sequelize.DATE,
      },
      updated_at: {
        allowNull: false,
        type: Sequelize.DATE,
      },
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('edu_users');
  },
};
